package com.jlpay.openapi.demo.trans.mini.wx;

import com.jlpay.open.jlpay.sdk.java.model.trans.mini.wx.request.OfficialPayRequest;
import com.jlpay.open.jlpay.sdk.java.model.trans.mini.wx.response.OfficialPayResponse;
import com.jlpay.open.jlpay.sdk.java.utils.json.JsonUtils;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author dengwenning
 * @since 2024/9/23
 **/
public class OfficialPayService {
    private static final Logger LOGGER = LoggerFactory.getLogger(OfficialPayService.class);

    public static void main(String[] args) {
        OfficialPayRequest officialPayRequest = buildOfficialPayRequest();
        OfficialPayResponse officialPayResponse = JlpayOpenApiService.openMerchService()
                .post(officialPayRequest, OfficialPayResponse.class);
        LOGGER.info("微信公众号/小程序支付下单响应:{}", JsonUtils.toString(officialPayResponse));
    }

    private static OfficialPayRequest buildOfficialPayRequest() {
        OfficialPayRequest officialPayRequest = new OfficialPayRequest();

        officialPayRequest.setMchId("849584358120018");
        officialPayRequest.setTermNo("60131234");
        officialPayRequest.setPayType("wxpay");
        officialPayRequest.setOpenId("oUpF8uMuAJO_M2pxb1Q9zNjWeS6o");
        officialPayRequest.setSubAppid("wxd930ea53421a258f4f");
        officialPayRequest.setLimitPay("no_credit");
        officialPayRequest.setOutTradeNo("ld201911023465529");
        officialPayRequest.setPaymentValidTime("10");
        officialPayRequest.setBody("充值中心-会员充值");
        officialPayRequest.setAttach("商城—-易拉宝10个打印纸20箱");
        officialPayRequest.setTotalFee("1");
        officialPayRequest.setRemark("该订单物流请走顺丰快递");
        officialPayRequest.setNotifyUrl("https://help.jlpay.com/api/docs/home");
        officialPayRequest.setOpUserId("001");
        officialPayRequest.setOpShopId("GD_SZ_001");
        officialPayRequest.setDeviceInfo("N50007A8890");
        officialPayRequest.setMchCreateIp("123.12.12.123");
        officialPayRequest.setLongitude("116.078631");
        officialPayRequest.setLatitude("39.71274");
        officialPayRequest.setGoodsTag("sz001");

        return officialPayRequest;
    }
}
